package com.seckill.goods.feign;

import com.seckill.goods.pojo.Sku;
import com.seckill.util.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/*****
 * @Author: http://www.itheima.com
 * @Project: seckill
 * @Description: com.seckill.goods.feign.SkuFeign
 ****/
@FeignClient(value = "seckill-goods",path = "/sku")
public interface SkuFeign {

    /***
     * 根据ID集合查询商品价格信息
     * @return
     * @throws Exception
     */
    @PostMapping("/list/range")
    List<Sku> seckillPrice(@RequestParam List<String> ids);

    /****
     * 库存递减
     */
    @PutMapping(value = "/dcount/{id}/{count}")
    Result<Sku> dcount(@PathVariable(value = "id") String id, @PathVariable(value = "count") Integer count);

    /***
     * 热点商品隔离
     */
    @PostMapping(value = "/hot/isolation")
    Result hotIsolation(@RequestParam List<String> ids);

    /****
     * 分页查询-查询总数量
     */
    @GetMapping(value = "/count")
    Result count();


    /****
     * 分页查询集合列表
     */
    @GetMapping(value = "/list/{page}/{size}")
    List<Sku> list(@PathVariable(value = "page") Integer page, @PathVariable(value = "size") Integer size);

    /***
     * 锁定商品
     */
    @GetMapping(value = "/lock/{id}")
    Result lock(@PathVariable(value = "id") String id);

    /***
     * 解锁商品
     */
    @GetMapping(value = "/unlock/{id}")
    Result unlock(@PathVariable(value = "id") String id);

    /***
     * 根据ID查询Sku数据
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    Result<Sku> findById(@PathVariable String id);

    /***
     * 商品数据归0
     */
    @GetMapping(value = "/zero/{id}")
    Result zero(@PathVariable(value = "id") String id);

    /**
     * 根据ID修改
     * @param sku
     * @return
     */
    @PutMapping(value="/{id}")
    Result modifyById(@RequestBody  Sku sku,@PathVariable String id);

}
